#
# File to run the demo, make release packages, etc.
#
# Do:  make             run the demo
#      make release     to build the release *.tgz
#      make clean       to clean up
#

VERSION=2.2

TILE_TARGET=tiles.NEW

ZIPDIR=./_release_tmp

REL_SRC_FILES=pyslip.py RELEASE

DEMO_SRC_FILES=log.py pyslip_demo.py pyslip_demo_net.py pyslip.py README tkinter_error.py
DEMO_SRC_DIRS=graphics tiles

MAKE_TILES_SRC_FILES=numofcpus.py make_gmt_tiles.py README.make_gmt_tiles


all:	netdemo

demo:
	-rm -f *.log
	python pyslip_demo.py

netdemo:
	-rm -f *.log
	python pyslip_demo_net.py

edit:
	-rm -f *.log
	python edit_text_layer.py

tiles:	
	rm -Rf $(TILE_TARGET)
	python make_gmt_tiles.py $(TILE_TARGET) 4 0
	@echo "Now rename $(TILE_TARGET) to tiles"

release: 
	@echo ""
	@echo "#################################################################"
	@echo "# THIS IS RELEASE: $(VERSION)"
	@echo "#################################################################"
	@echo ""
	rm -Rf $(ZIPDIR)
	@echo "#####  Making pyslip release  #####"
	mkdir -p $(ZIPDIR)/pyslip
	cp $(REL_SRC_FILES) $(ZIPDIR)/pyslip
	(cd $(ZIPDIR); tar czf pyslip_$(VERSION).tgz pyslip; cp pyslip_$(VERSION).tgz ..)
	@echo "#####  Making pyslip_demo release  #####"
	mkdir -p $(ZIPDIR)/pyslip_demo
	cp -rL $(DEMO_SRC_DIRS) $(ZIPDIR)/pyslip_demo
	cp $(DEMO_SRC_FILES) $(ZIPDIR)/pyslip_demo
	-find $(ZIPDIR)/pyslip_demo -type d -name .svn -exec rm -Rf {} \; 2>/dev/null
	(cd $(ZIPDIR); tar czf pyslip_demo_$(VERSION).tgz pyslip_demo; cp pyslip_demo_$(VERSION).tgz ..)
	cp pyslip_*.tgz ..
	@echo "#####  Making make_gmt_tiles release  #####"
	mkdir -p $(ZIPDIR)/make_gmt_tiles
	cp $(MAKE_TILES_SRC_FILES) $(ZIPDIR)/make_gmt_tiles
	mv $(ZIPDIR)/make_gmt_tiles/README.make_gmt_tiles $(ZIPDIR)/make_gmt_tiles/README
	(cd $(ZIPDIR); tar czf make_gmt_tiles_$(VERSION).tgz make_gmt_tiles; cp make_gmt_tiles_$(VERSION).tgz ..)
	cp make_gmt_tiles_*.tgz ..
	rm -Rf $(ZIPDIR)

count:
	@echo "#####  Counting lines of code  #####"
	sloccount . | sed -e "1,/^SLOC/d" > sloccount.out
	@echo "Created file sloccount.out"
	@grep "^python" sloccount.out

clean:
	rm -f *.pyc *.log *.tgz *.zip *.tmp IO_int.grd *~ *.out
	rm -Rf $(ZIPDIR)
